package com.dmlll.controller;

import com.dmlll.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * 公用请求
 */
@RestController
public class CommonController {
    /**
     * 获得session中的单位
     * @param session
     * @return
     */
    @RequestMapping("/getSessionUnitId")
    public Integer getSessionUnitId(HttpSession session){
        User user = (User) session.getAttribute("user");
        if(null!=user&&user.getUnitId()!=null){
            return user.getUnitId();
        }
        //不存在
        return 0;
    }
}
